package com.ruoyi.smart.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.smart.domain.SmartTest;
import com.ruoyi.smart.service.ISmartTestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 测试Controller
 * 
 * @author minwei
 * @date 2022-04-19
 */
//@Api("测试")
@RestController
@RequestMapping("/smart/test")
public class SmartTestController extends BaseController
{
    @Autowired
    private ISmartTestService smartTestService;

    /**
     * 查询测试列表
     */
    @PreAuthorize("@ss.hasPermi('smart:test:list')")
    @GetMapping("/list")
    //@ApiOperation("查询测试列表")
    public TableDataInfo list(SmartTest smartTest)
    {
        startPage();
        List<SmartTest> list = smartTestService.selectSmartTestList(smartTest);
        return getDataTable(list);
    }

    /**
     * 导出测试列表
     */
    @PreAuthorize("@ss.hasPermi('smart:test:export')")
    @Log(title = "测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SmartTest smartTest)
    {
        List<SmartTest> list = smartTestService.selectSmartTestList(smartTest);
        ExcelUtil<SmartTest> util = new ExcelUtil<SmartTest>(SmartTest.class);
        util.exportExcel(response, list, "测试数据");
    }

    /**
     * 获取测试详细信息
     */
    //@ApiOperation("获取测试详细信息")
    @PreAuthorize("@ss.hasPermi('smart:test:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(smartTestService.selectSmartTestById(id));
    }

    /**
     * 新增测试
     */
    //@ApiOperation("新增测试")
    @PreAuthorize("@ss.hasPermi('smart:test:add')")
    @Log(title = "测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SmartTest smartTest)
    {
        return toAjax(smartTestService.insertSmartTest(smartTest));
    }

    /**
     * 修改测试
     */
    //@ApiOperation("修改测试")
    @PreAuthorize("@ss.hasPermi('smart:test:edit')")
    @Log(title = "测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SmartTest smartTest)
    {
        return toAjax(smartTestService.updateSmartTest(smartTest));
    }

    /**
     * 删除测试
     */
    //@ApiOperation("删除测试")
    @PreAuthorize("@ss.hasPermi('smart:test:remove')")
    @Log(title = "测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(smartTestService.deleteSmartTestByIds(ids));
    }
}
